.class public Lcom/instagram/android/d/i/f;
.super Ljava/lang/Object;
.source "RequestUtil.java"


# static fields
.field public static a:Ljava/lang/String;

.field public static b:Ljava/lang/String;

.field static c:Ljava/lang/String;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 25
    const-string v0, "ig_sig_key_version"

    sput-object v0, Lcom/instagram/android/d/i/f;->a:Ljava/lang/String;

    .line 26
    const-string v0, "4"

    sput-object v0, Lcom/instagram/android/d/i/f;->b:Ljava/lang/String;

    .line 28
    const/4 v0, 0x0

    sput-object v0, Lcom/instagram/android/d/i/f;->c:Ljava/lang/String;

    return-void
.end method

.method public static a(Lcom/instagram/android/d/b/c;)Lcom/instagram/android/d/b/c;
    .locals 2
    .parameter

    .prologue
    .line 38
    invoke-virtual {p0}, Lcom/instagram/android/d/b/c;->h()Lcom/instagram/android/d/b/b;

    move-result-object v0

    invoke-virtual {v0}, Lcom/instagram/android/d/b/b;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/instagram/android/d/i/f;->a(Ljava/lang/String;)Lcom/instagram/android/d/b/c;

    move-result-object v0

    .line 39
    invoke-virtual {p0}, Lcom/instagram/android/d/b/c;->b()Ljava/util/Map;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/instagram/android/d/b/c;->a(Ljava/util/Map;)V

    .line 40
    return-object v0
.end method

.method public static a(Ljava/lang/String;)Lcom/instagram/android/d/b/c;
    .locals 6
    .parameter

    .prologue
    .line 31
    new-instance v0, Lcom/instagram/android/d/b/c;

    invoke-direct {v0}, Lcom/instagram/android/d/b/c;-><init>()V

    .line 32
    const-string v1, "signed_body"

    const-string v2, "%s.%s"

    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    invoke-static {p0}, Lcom/instagram/android/d/i/f;->b(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v3, v4

    const/4 v4, 0x1

    aput-object p0, v3, v4

    invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v1, v2}, Lcom/instagram/android/d/b/c;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 33
    sget-object v1, Lcom/instagram/android/d/i/f;->a:Ljava/lang/String;

    sget-object v2, Lcom/instagram/android/d/i/f;->b:Ljava/lang/String;

    invoke-virtual {v0, v1, v2}, Lcom/instagram/android/d/b/c;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 34
    return-object v0
.end method

.method private static a()Ljavax/crypto/Mac;
    .locals 6

    .prologue
    const/4 v1, 0x0

    const/4 v0, 0x0

    .line 93
    sget-object v2, Lcom/instagram/android/d/i/f;->c:Ljava/lang/String;

    if-eqz v2, :cond_0

    .line 95
    :try_start_0
    sget-object v2, Lcom/instagram/android/d/i/f;->c:Ljava/lang/String;

    invoke-static {v2}, Ljavax/crypto/Mac;->getInstance(Ljava/lang/String;)Ljavax/crypto/Mac;
    :try_end_0
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    .line 114
    :goto_0
    return-object v0

    .line 96
    :catch_0
    move-exception v2

    .line 100
    :cond_0
    const/4 v2, 0x6

    new-array v3, v2, [Ljava/lang/String;

    const-string v2, "HmacSHA256"

    aput-object v2, v3, v0

    const/4 v2, 0x1

    const-string v4, "hmacSHA256"

    aput-object v4, v3, v2

    const/4 v2, 0x2

    const-string v4, "HMAC-SHA256"

    aput-object v4, v3, v2

    const/4 v2, 0x3

    const-string v4, "hmac-sha256"

    aput-object v4, v3, v2

    const/4 v2, 0x4

    const-string v4, "HMAC/SHA256"

    aput-object v4, v3, v2

    const/4 v2, 0x5

    const-string v4, "hmac/sha256"

    aput-object v4, v3, v2

    .line 101
    array-length v4, v3

    move v2, v0

    :goto_1
    if-ge v2, v4, :cond_2

    aget-object v5, v3, v2

    .line 104
    :try_start_1
    invoke-static {v5}, Ljavax/crypto/Mac;->getInstance(Ljava/lang/String;)Ljavax/crypto/Mac;
    :try_end_1
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_1 .. :try_end_1} :catch_1

    move-result-object v0

    .line 108
    :goto_2
    if-eqz v0, :cond_1

    .line 109
    sput-object v5, Lcom/instagram/android/d/i/f;->c:Ljava/lang/String;

    goto :goto_0

    .line 105
    :catch_1
    move-exception v0

    move-object v0, v1

    goto :goto_2

    .line 101
    :cond_1
    add-int/lit8 v0, v2, 0x1

    move v2, v0

    goto :goto_1

    :cond_2
    move-object v0, v1

    .line 114
    goto :goto_0
.end method

.method public static a(Lcom/instagram/android/d/b/e;Lcom/instagram/android/d/c/f;)V
    .locals 4
    .parameter
    .parameter

    .prologue
    .line 46
    invoke-interface {p1}, Lcom/instagram/android/d/c/f;->a()Lcom/instagram/android/d/b/a;

    move-result-object v0

    sget-object v1, Lcom/instagram/android/d/b/a;->a:Lcom/instagram/android/d/b/a;

    if-ne v0, v1, :cond_3

    .line 47
    invoke-static {}, Lcom/instagram/service/PersistentCookieStore;->a()Lcom/instagram/service/PersistentCookieStore;

    move-result-object v0

    invoke-virtual {v0}, Lcom/instagram/service/PersistentCookieStore;->getCookies()Ljava/util/List;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v1

    :cond_0
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_1

    invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lch/boye/httpclientandroidlib/cookie/Cookie;

    .line 48
    const-string v2, "csrftoken"

    invoke-interface {v0}, Lch/boye/httpclientandroidlib/cookie/Cookie;->getName()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 49
    const-string v2, "_csrftoken"

    invoke-interface {v0}, Lch/boye/httpclientandroidlib/cookie/Cookie;->getValue()Ljava/lang/String;

    move-result-object v0

    invoke-interface {p0, v2, v0}, Lcom/instagram/android/d/b/e;->a(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0

    .line 53
    :cond_1
    invoke-static {}, Lcom/instagram/service/a;->a()Lcom/instagram/service/a;

    move-result-object v0

    invoke-virtual {v0}, Lcom/instagram/service/a;->b()Lcom/instagram/android/model/b/e;

    move-result-object v0

    if-eqz v0, :cond_3

    .line 54
    invoke-interface {p1}, Lcom/instagram/android/d/c/f;->e()Z

    move-result v0

    if-eqz v0, :cond_2

    .line 55
    const-string v0, "_uuid"

    invoke-static {}, Lcom/instagram/e/a/a;->a()Landroid/content/Context;

    move-result-object v1

    invoke-static {v1}, Lcom/instagram/android/util/b;->b(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v1

    invoke-interface {p0, v0, v1}, Lcom/instagram/android/d/b/e;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 57
    :cond_2
    invoke-interface {p1}, Lcom/instagram/android/d/c/f;->d()Z

    move-result v0

    if-eqz v0, :cond_3

    .line 58
    const-string v0, "_uid"

    invoke-static {}, Lcom/instagram/service/a;->a()Lcom/instagram/service/a;

    move-result-object v1

    invoke-virtual {v1}, Lcom/instagram/service/a;->b()Lcom/instagram/android/model/b/e;

    move-result-object v1

    invoke-virtual {v1}, Lcom/instagram/android/model/b/e;->k()Ljava/lang/String;

    move-result-object v1

    invoke-interface {p0, v0, v1}, Lcom/instagram/android/d/b/e;->a(Ljava/lang/String;Ljava/lang/String;)V

    .line 62
    :cond_3
    return-void
.end method

.method public static b(Ljava/lang/String;)Ljava/lang/String;
    .locals 5
    .parameter

    .prologue
    .line 65
    const/4 v1, 0x0

    .line 66
    const-string v0, "a4d1b77bbb1a4a5ca695ad72c84b77e5"

    invoke-static {v0}, Lcom/instagram/strings/StringBridge;->getInstagramString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v0

    .line 69
    :try_start_0
    invoke-static {}, Lcom/instagram/android/d/i/f;->a()Ljavax/crypto/Mac;

    move-result-object v2

    .line 70
    new-instance v3, Ljavax/crypto/spec/SecretKeySpec;

    const-string v4, "UTF-8"

    invoke-virtual {v0, v4}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v0

    invoke-virtual {v2}, Ljavax/crypto/Mac;->getAlgorithm()Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v0, v4}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V

    .line 71
    invoke-virtual {v2, v3}, Ljavax/crypto/Mac;->init(Ljava/security/Key;)V

    .line 73
    invoke-virtual {p0}, Ljava/lang/String;->getBytes()[B

    move-result-object v0

    invoke-virtual {v2, v0}, Ljavax/crypto/Mac;->doFinal([B)[B

    move-result-object v0

    .line 76
    new-instance v2, Ljava/math/BigInteger;

    const/4 v3, 0x1

    invoke-direct {v2, v3, v0}, Ljava/math/BigInteger;-><init>(I[B)V

    .line 77
    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "%0"

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    array-length v0, v0

    shl-int/lit8 v0, v0, 0x1

    invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v3, "x"

    invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const/4 v3, 0x1

    new-array v3, v3, [Ljava/lang/Object;

    const/4 v4, 0x0

    aput-object v2, v3, v4

    invoke-static {v0, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v0

    .line 83
    :goto_0
    return-object v0

    .line 78
    :catch_0
    move-exception v0

    .line 79
    const-string v2, "failed_to_generate_signature"

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v3

    if-eqz v3, :cond_0

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v0

    :goto_1
    invoke-static {v2, v0}, Lcom/instagram/g/c;->b(Ljava/lang/String;Ljava/lang/String;)V

    move-object v0, v1

    goto :goto_0

    :cond_0
    invoke-virtual {v0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/Class;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_1
.end method
